package com.atguigu.dga.common.utils;

import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;

public class HttpUtil {

   static OkHttpClient okHttpClient=   new OkHttpClient();


   public  static  String get(String url){
       //构造一个请求 填写相关参数
       Request request = new Request.Builder().url(url).get().build();
       Call call = okHttpClient.newCall(request); //创建一次http请求的会话
       try {
           Response response = call.execute(); //执行会话
           return    response.body().string() ;//结果返回
       } catch (IOException e) {
           throw new RuntimeException(e);
       }

   }

    public static void main(String[] args) {
        String json = HttpUtil.get("http://hadoop102:18080/api/v1/applications/application_1719799382747_0001");
        System.out.println("json = " + json);
    }

}
